import Mock from 'mockjs';

// 生成模拟用户数据
const users = Mock.mock({
  'list|10': [{
    'username|1': ['user1', 'user2', 'user3', 'user4'],
    'password|1': ['password1', 'password2', 'password3', 'password4'],
  }],
}).list;

Mock.mock('/api/login', 'post', (options) => {
  const { username, password } = JSON.parse(options.body);
  const user = users.find(
    (u) => u.username === username && u.password === password
  );
  return user ? { success: true, message: '登录成功' } : { success: false, message: '账号或密码错误' };
});
